<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui" template="template.xhtml">

	<ui:define name="main">
		<h:form id="formTurma" prependId="false">
			<div class="header header_turma" />
			<p:message for="painel" />
			<p:panel id="painelCadastro" header="#{msgs.cadastro_turmas}"
				styleClass="painelCadastro">
								
				<h:panelGrid columns="2" width="90%">
					<h:panelGrid columns="2" width="60%">
						<h:outputLabel value="#{msgs.nome_turma}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.curso}#{msgs.dois_pontos}" />
						<p:inputText id="nome_turma" value="#{turmaBean.turma.descTurma}"
							maxlength="45" required="true">
							<p:message for="nome_turma" />
						</p:inputText>
						<h:selectOneMenu value="#{turmaBean.idCurso}" id="curso">
							<f:selectItem itemLabel="#{msgs.selecione}" itemValue="0" />
							<f:selectItems value="#{turmaBean.selectItensCursos}" />
							<p:ajax listener="#{turmaBean.popularSerie}"
								update="series,panelSerie,id_periodo" process="@this" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="curso" />
						</h:selectOneMenu>
						<h:outputLabel value="#{msgs.serie}#{msgs.dois_pontos}" />
						<h:outputLabel value="#{msgs.periodo}#{msgs.dois_pontos}" />
						
						<h:selectOneMenu id="series" value="#{turmaBean.idSerie}"
							disabled="#{empty turmaBean.listaSeries}">
							<f:selectItem itemLabel="#{msgs.selecione}" itemValue="0" />
							<f:selectItems value="#{turmaBean.selectItensSeries}" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
							<p:message for="series" />
							<p:ajax update="panelSerie" process="@this"
								listener="#{turmaBean.atualizarSerie}" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
						</h:selectOneMenu>
						<h:selectOneMenu id="id_periodo" value="#{turmaBean.idPeriodo}"
							required="true" disabled="#{empty turmaBean.listaSeries}">
							<f:selectItem itemLabel="#{msgs.selecione}" itemValue="0" />
							<f:selectItems value="#{turmaBean.selectItensPeriodos}" />
							<p:message for="id_periodo" />
							<f:validator
								validatorId="br.com.pirralhos.view.validation.ComboValidator" />
						</h:selectOneMenu>
						
					</h:panelGrid>
					<h:panelGrid style="width:100%">
						<p:outputPanel id="panelSerie">
							<p:panel id="infoSerie"
								rendered="#{not empty turmaBean.serie.idserie}"
								header="#{msgs.informacoes_serie}">
								<h:panelGrid>
									<h:outputLabel
										value="Quantidade M&iacute;nima de professores:#{turmaBean.serie.qtdMinimaProfessores}" />
									<h:outputLabel
										value="Quantidade M&aacute;xima de professores:#{turmaBean.serie.qtdMaximaProfessores}" />
									<h:outputLabel
										value="Faixa de idade aluno: De #{turmaBean.serie.idadeMinimaMeses} meses a #{turmaBean.serie.idadeMaximaMeses} meses" />
								</h:panelGrid>
							</p:panel>
						</p:outputPanel>
					</h:panelGrid>
				</h:panelGrid>

				<h:outputLabel value="#{msgs.professores}#{msgs.dois_pontos}" />
				
				<p:pickList value="#{turmaBean.professores}" var="professor"
					itemValue="#{professor}" itemLabel="#{professor.nome}"
					converter="br.com.pirralhos.view.converter.ProfessorConverter"
					addLabel="#{msgs.adicionar}" addAllLabel="#{msgs.adicionar_todos}"
					removeLabel="#{msgs.remover}" id="painel"
					removeAllLabel="#{msgs.remover_todos}" />
			</p:panel>
			<h:panelGrid styleClass="painelBotoes" columns="2">
				<p:commandButton value="#{msgs.botao_gravar}"
					action="#{turmaBean.gravar}" ajax="false" />

				<p:commandButton value="#{msgs.botao_limpar}"
					action="#{turmaBean.limpar}" update="painelCadastro"
					process="@this" />
			</h:panelGrid>
			
			<h:panelGrid style="height:100px" columns="2">
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>
